<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="成本域" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="costDomain">
              <a-input v-model="model.costDomain" placeholder="请输入成本域"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description1">
              <a-input v-model="model.description1" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易对象" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionObject">
              <a-input v-model="model.transactionObject" placeholder="请输入交易对象"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易对象简称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionObjectAbbr">
              <a-input v-model="model.transactionObjectAbbr" placeholder="请输入交易对象简称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="委外工单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outsourcingOrder">
              <a-input v-model="model.outsourcingOrder" placeholder="请输入委外工单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="参考单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="referenceOrder">
              <a-input v-model="model.referenceOrder" placeholder="请输入参考单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="项次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="itemSequence">
              <a-input v-model="model.itemSequence" placeholder="请输入项次"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="项序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="itemOrder">
              <a-input v-model="model.itemOrder" placeholder="请输入项序"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="采购单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseOrder">
              <a-input v-model="model.purchaseOrder" placeholder="请输入采购单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="收料单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receiptOrder">
              <a-input v-model="model.receiptOrder" placeholder="请输入收料单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发票号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="invoiceNumber">
              <a-input v-model="model.invoiceNumber" placeholder="请输入发票号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出入库码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inOutCode">
              <a-input v-model="model.inOutCode" placeholder="请输入出入库码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="documentDate">
              <a-input v-model="model.documentDate" placeholder="请输入单据日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="料号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCode">
              <a-input v-model="model.materialCode" placeholder="请输入料号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="品名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productName">
              <a-input v-model="model.productName" placeholder="请输入品名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="规格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specification">
              <a-input v-model="model.specification" placeholder="请输入规格"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="财务分群(成本分群)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="financialGroup">
              <a-input v-model="model.financialGroup" placeholder="请输入财务分群(成本分群)"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description2">
              <a-input v-model="model.description2" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="产品特征" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productFeature">
              <a-input v-model="model.productFeature" placeholder="请输入产品特征"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="仓库编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouseCode">
              <a-input v-model="model.warehouseCode" placeholder="请输入仓库编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description3">
              <a-input v-model="model.description3" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="批号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batchNumber">
              <a-input v-model="model.batchNumber" placeholder="请输入批号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="成本单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="costUnit">
              <a-input v-model="model.costUnit" placeholder="请输入成本单位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description4">
              <a-input v-model="model.description4" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期异动数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionQty">
              <a-input v-model="model.transactionQty" placeholder="请输入本期异动数量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionCurrency">
              <a-input v-model="model.transactionCurrency" placeholder="请输入交易币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description5">
              <a-input v-model="model.description5" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="汇率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exchangeRate">
              <a-input v-model="model.exchangeRate" placeholder="请输入汇率"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期异动单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionPrice">
              <a-input v-model="model.transactionPrice" placeholder="请输入本期异动单价"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期异动金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="transactionAmount">
              <a-input v-model="model.transactionAmount" placeholder="请输入本期异动金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="成本中心" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="costCenter">
              <a-input v-model="model.costCenter" placeholder="请输入成本中心"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明(简称)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="descriptionAbbr">
              <a-input v-model="model.descriptionAbbr" placeholder="请输入说明(简称)"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="原币金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="originalAmount">
              <a-input v-model="model.originalAmount" placeholder="请输入原币金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本币金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="localAmount">
              <a-input v-model="model.localAmount" placeholder="请输入本币金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="账款编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountNumber">
              <a-input v-model="model.accountNumber" placeholder="请输入账款编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="产品分类码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productCategory">
              <a-input v-model="model.productCategory" placeholder="请输入产品分类码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description6">
              <a-input v-model="model.description6" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="账款类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountType">
              <a-input v-model="model.accountType" placeholder="请输入账款类别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description7">
              <a-input v-model="model.description7" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="付款方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paymentMethod">
              <a-input v-model="model.paymentMethod" placeholder="请输入付款方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description8">
              <a-input v-model="model.description8" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="税种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taxType">
              <a-input v-model="model.taxType" placeholder="请输入税种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description9">
              <a-input v-model="model.description9" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="科目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountCode">
              <a-input v-model="model.accountCode" placeholder="请输入科目编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description10">
              <a-input v-model="model.description10" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="原因码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reasonCode">
              <a-input v-model="model.reasonCode" placeholder="请输入原因码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description11">
              <a-input v-model="model.description11" placeholder="请输入说明"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="凭证号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="voucherNumber">
              <a-input v-model="model.voucherNumber" placeholder="请输入凭证号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="年份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year">
              <a-input v-model="model.year" placeholder="请输入年份"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="月份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="month">
              <a-input v-model="model.month" placeholder="请输入月份"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="据点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="site">
              <a-input v-model="model.site" placeholder="请输入据点"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'Axcq508ChAllForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/ch/axcq508ChAll/add",
          edit: "/ch/axcq508ChAll/edit",
          queryById: "/ch/axcq508ChAll/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>